<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学员预约考试修改</title>
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <link href="../../static/css/style.css" rel="stylesheet">
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../static/js/base.js"></script>
    <script src="../../static/js/ax.js"></script>
    <script src="../../static/js/avalon.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->

</head>
<body class="bg_w">

<div class="xyxx" ms-controller="test">
    <div class="layui-card-body">
        <form class="layui-form layui-form-pane" action="" lay-filter="component-form-element">
            <div class="layui-row layui-col-space10 layui-form-item">
                <div class="layui-col-lg3 layui-form-text layui-col-sm6">
                    <div class="layui-form-item student_name" pane="">
                        <label class="layui-form-label" style="position: relative;">学员姓名</label>
                        <div class="layui-input-block">
                            <ul>
                                <li><label>{{@studenname}}-{{@certificatesNumber}}-{{@carName}}</label><input type="hidden" ms-attr="{value:@studentid}"></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!--<div class="layui-col-lg3 layui-col-sm6">-->
                    <!--<a type="reset" class="layui-btn add_btn" id="searchname">搜索</a>-->
                <!--</div>-->

            </div>
            <div class="layui-row layui-col-space10 layui-form-item">
                <div class="layui-inline  layui-col-lg3 layui-col-sm6">
                    <label class="layui-form-label">考试时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="examTime" :duplex="@examTime" lay-filter="examtime" id="enrolltime" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-col-lg3 layui-col-sm6">
                    <label class="layui-form-label">考试科目</label>
                    <div class="layui-input-block">
                        <input type="text" name="examSubject" ms-attr="{value:@classname}" disabled class="layui-input">
                    </div>
                </div>
                <div class="layui-inline  layui-col-lg3 layui-col-sm6">
                    <label class="layui-form-label">考试地点</label>
                    <div class="layui-input-block">
                        <input type="text" name="examAddress" ms-attr="{value:@addressactive}" id="addressbtn" class="layui-input">
                    </div>
                    <div class="layui-form-item  layui-col-sm12" :if="@address" >
                        <div class="layui-row" style="border: 1px solid #e6e6e6; padding: 10px 15px;">
                            <div class="layui-inline layui-col-sm12">
                                <label class="layui-form-label">地点名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="enrolltime" id="testaddress" class="layui-input" style="float: left;width: 60%;">
                                    <a type="reset" class="layui-btn add_btn" style="float: right;">搜索</a>
                                </div>
                            </div>
                            <div class="layui-form-item">

                                <select name="interest" lay-filter="address" ms-duplex="@addressactive">
                                    <option value=""></option>
                                    <option value="0">重庆</option>
                                    <option value="1" selected="">北京</option>
                                    <option value="2">上海</option>
                                    <option value="3">四川</option>
                                    <option value="4">云南</option>
                                </select>

                            </div>
                        </div>

                    </div>

                </div>
                <div class="layui-col-lg3 layui-col-sm6">
                    <a type="reset" class="layui-btn add_btn" :click="addresssearch()">搜索</a>
                </div>

                <input type="hidden" id="classname" ms-attr="{value:@classname}">
                <input type="hidden" id="studentdata"   ms-duplex="@studentdata">

            </div>
            <!--模板-->

            <div class="layui-form-item layui-col-space10">
                <div class="layui-input-block">
                    <button id="btnClose" class="layui-btn layui-btn-primary btn-left">关闭</button>
                    <button class="layui-btn add_btn btn-left" lay-submit lay-filter="component-form-element">提交</button>

                </div>
            </div>
        </form>
    </div>
</div>


</body>

<script>
    var studenteid=getQueryString("studentId");
    var vm = avalon.define({
        $id: "test",
        studentlist:[],
        classname:'',
        address:false,
        addressactive:'',
        studentid:[],
        examTime:'',
        stuid:[],
        studentdata:'',
        //获取学员信息
        getstudent:function(){

        },

        //地址搜索
        addresssearch:function () {
            vm.address=true;
            setTimeout(function () {
                form.render('select')
            },200)

        },
    });

    vm.$watch('onReady', function () {

        if(classname==1){
            vm.classname='科目一'
        }
        if(classname==2){
            vm.classname='科目二'
        }
        if(classname==3){
            vm.classname='科目三'
        }
        if(classname==4){
            vm.classname='科目四'
        }

    });

    var table;
    var form;

    layui.use(['table','form','laydate','layer','upload'], function() {
        table = layui.table;
        form = layui.form;
        var laydate = layui.laydate,
            layer=layui.layer,
            $ = layui.jquery,
            upload = layui.upload;

        //常规用法
        laydate.render({
            elem: '#enrolltime'
        });


        //监听提交
        form.on('submit(component-form-element)', function(data){
            var ss=[];
            for(var s in vm.stuid){
                var list={"studentId":vm.stuid[s].studentId,"examSubject":datas,"examTime":data.field.examTime,"examAddress":data.field.examAddress}
                ss.push(list)
            }

            console.log(JSON.stringify(ss))
            ax.post({
                url: schoolWebUrl + "/api/studentExam/studentYueKaoExamAdd",
                data: JSON.stringify(ss),
                success: function (data) {
                    // layer.msg(data.message);
                    if (data.code == 0) {
                        //刷新父页面
                        layer.msg('约考成功')
                        //刷新父页面
                        topFrame.location.reload();
                        setTimeout(function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                        },300)
                    } else {
                        layer.msg('约考失败')
                    }
                }
            });
            return false;

        });
        form.on('select(address)', function(data){
            vm.addressactive=data.value;
        });
        form.on('input(examtime)', function(data){
            vm.examTime=data.value;
        });
        //关闭弹窗
        $('#btnClose').on("click", function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });

    });



</script>
</html>